package com.uphone.magicleafteacher.pro.fragment.message;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;

import com.radish.baselibrary.navigationbar.DefaultNavigationBar;
import com.uphone.magicleafteacher.MyApp;
import com.uphone.magicleafteacher.base.BaseListFragment;
import com.uphone.magicleafteacher.http.ApiService;
import com.uphone.magicleafteacher.pro.adapter.MessageApapter;
import com.uphone.magicleafteacher.util.CommonUtil;
import com.uphone.magicleafteacher.util.GsonUtils;
import com.uphone.magicleafteacher.vo.TeacherMsgBean;

import java.util.List;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

public class MessageFragment extends BaseListFragment<TeacherMsgBean.MsgListBean, MessageApapter> {
    public static MessageFragment newInstance(String title) {

        Bundle args = new Bundle();

        MessageFragment fragment = new MessageFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected Observable<ResponseBody> loadData(ApiService apiService) {
        return MyApp.apiService(ApiService.class)
                .teacherMsg(CommonUtil.getTeacherId(), page + "", "10");
    }

    @Override
    protected List<TeacherMsgBean.MsgListBean> getDataList(String json) {
        TeacherMsgBean bean = GsonUtils.getGson().fromJson(json, TeacherMsgBean.class);
        if (bean != null)
            return bean.getMsgList();
        return null;
    }

    @Override
    protected void itemClick(MessageApapter adapter, View view, int position) {

    }

    @Override
    protected MessageApapter initAdapter() {
        return new MessageApapter();
    }

    @Override
    protected void initBundle() {

    }

    @Override
    protected void initView() {
        super.initView();
        new DefaultNavigationBar.Builder(getActivity(), ll)
//                .setLineColor(getResources().getColor(R.color.color_graye))
                .setTitle(CommonUtil.getStr("消息"))
                .builder()
                .getLeftIcon()
                .setVisibility(View.GONE);
        ll.setBackgroundColor(Color.WHITE);
    }
}
